/**
  * Defines a set of functions for using the LCD panel provided with
  * the CE2800/CE2810 SunRom Development Kit.
  *
  * @author t a y l o r@msoe.edu
  * @version 2008.03.12
  */

#ifndef _LCD_H
#define _LCD_H

/**
  * Hitachi HD44780 commands
  * The following defines common commands used with the LCD.
  */

#define LCD_CLR             0x01    // clear display
#define LCD_HOME            0x02    // return to home position
#define LCD_CURSOR_RIGHT    0x14    // move cursor right
#define LCD_CURSOR_LEFT     0x10    // move cursor left
#define LCD_SHIFT_RIGHT     0x1C    // shift display right
#define LCD_SHIFT_LEFT      0x18    // shift display left

#define LCD_ENTRY_MODE      2       // set entry mode
#define LCD_ENTRY_INC       1       // increment
#define LCD_ENTRY_SHIFT     0       // shift
#define LCD_ON_CTRL         3       // turn on lcd/cursor
#define LCD_ON_DISPLAY      2       // turn on display
#define LCD_ON_CURSOR       1       // turn on cursor
#define LCD_ON_BLINK        0       // blinking cursor
#define LCD_MOVE            4       // move cursor/display
#define LCD_MOVE_DISP       3       // move display (0-> move cursor)
#define LCD_MOVE_RIGHT      2       // move right (0-> left)
#define LCD_FUNCTION        5       // function set
#define LCD_FUNCTION_8BIT   4       // set 8BIT mode (0->4BIT mode)
#define LCD_FUNCTION_2LINES 3       // two lines (0->one line)
#define LCD_FUNCTION_10DOTS 2       // 5x10 font (0->5x7 font)
#define LCD_DDRAM			7		// Set DDRAM address


/**
  * Initializes the LCD so that it is ready display values.
  *
  * The initialization process must configure the appropriate port
  * by sending initialization commands to the LCD.  The port used in
  * the initialization here will be used by the other functions in
  * this library.
  *
  * @param port A character 'A', 'B', 'C' or 'D' designating the port
  *               to which the LCD is connected.
  */
void lcd_init(char port);

/**
  * Send the cursor to the home position on the LCD.
  */
void lcd_home(void);

/**
  * Clear the LCD panel.
  */
void lcd_clear(void);

/**
  * Move the cursor to the specified position on the LCD panel.
  *
  * @param x Horizontal position of the cursor.
  * @param y Vertical position of the cursor.
  */
void lcd_goto_xy(uint8_t x,uint8_t y);

/**
  * Display a character on the LCD panel at the cursor's current position.
  *
  * @param symbol Character to be displayed.
  */
void lcd_print_char(char symbol);

/**
  * Display a sequence of characters on the LCD panel beginning at
  * the cursor's current position.
  *
  * @param string A pointer to a null-terminated sequence of characters.
  */
void lcd_print_string(char string[]);

/**
  * Display a hexidecimal value on the LCD panel beginning at the
  * cursor's current position.
  *
  * @param hex The value to be displayed.
  */
void lcd_print_hex(uint8_t hex);

/**
  * Display an unsiged 8-bit integer value on the LCD panel beginning at the
  * cursor's current position.
  *
  * @param no The value to be displayed.
  */
void lcd_print_uint8(uint8_t no);

/**
  * Display a signed 8-bit integer value on the LCD panel beginning at the
  * cursor's current position.
  *
  * IMPLEMENTATION OF THIS METHOD IS WORTH 5 POINTS.  You are not required
  * to implement it; however, the best grade you may receive on this assignment
  * is 95% if this method is not implemented.
  *
  * @param no The value to be displayed.
  */
void lcd_print_int8(int8_t no);

/**
  * Display an unsiged 16-bit integer value on the LCD panel beginning at the
  * cursor's current position.
  *
  * IMPLEMENTATION OF THIS METHOD IS OPTIONAL.
  *
  * @param no The value to be displayed.
  */
void lcd_print_uint16(uint16_t no);

/**
  * Display a signed 16-bit integer value on the LCD panel beginning at the
  * cursor's current position.
  *
  * IMPLEMENTATION OF THIS METHOD IS OPTIONAL.
  *
  * @param no The value to be displayed.
  */
void lcd_print_int16(int16_t no);

/**
  * Display a floating point value on the LCD panel beginning at the
  * cursor's current position.
  *
  * IMPLEMENTATION OF THIS METHOD IS OPTIONAL.
  *
  * @param no The value to be displayed.
  */
void lcd_print_float(float no);

#endif
